import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GermplasmVO, GermplasmForm, GermplasmQuery } from '@/api/agriculture/germplasm/types';

/**
 * 查询种质列表
 * @param query
 * @returns {*}
 */

export const listGermplasm = (query?: GermplasmQuery): AxiosPromise<GermplasmVO[]> => {
  return request({
    url: '/agriculture/germplasm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询种质详细
 * @param germplasmId
 */
export const getGermplasm = (germplasmId: string | number): AxiosPromise<GermplasmVO> => {
  return request({
    url: '/agriculture/germplasm/' + germplasmId,
    method: 'get'
  });
};

/**
 * 新增种质
 * @param data
 */
export const addGermplasm = (data: GermplasmForm) => {
  return request({
    url: '/agriculture/germplasm',
    method: 'post',
    data: data
  });
};

/**
 * 修改种质
 * @param data
 */
export const updateGermplasm = (data: GermplasmForm) => {
  return request({
    url: '/agriculture/germplasm',
    method: 'put',
    data: data
  });
};

/**
 * 删除种质
 * @param germplasmId
 */
export const delGermplasm = (germplasmId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/germplasm/' + germplasmId,
    method: 'delete'
  });
};
